package com.kkb.retailer.center.controller;


import com.github.pagehelper.PageInfo;

import com.kkb.retailer.center.api.BrandInfoService;
import com.kkb.retailer.center.common.http.HttpResult;
import com.kkb.retailer.center.common.pojo.BrandInfo;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api")
public class BrandController {

    @Reference
    private BrandInfoService brandInfoService;


    @GetMapping("/getBrand")
    public HttpResult getBrand(@RequestParam(value = "page",defaultValue = "1")int pageNo,
                               @RequestParam(value = "pageSize",defaultValue = "10")int pageSize){
        PageInfo<BrandInfo> brands = brandInfoService.getBrand(pageNo+1,pageSize);
        return HttpResult.success(brands);
    }

    @GetMapping("/getAllBrand")
    public HttpResult getAllBrand(){
        List<BrandInfo> all = brandInfoService.getAllBrand();
        return HttpResult.success(all);
    }


}
